package com.data;

/**
 * A connected edge. It consists of 2 nodes. It can be a node-node self-edge.
 * 
 * @author bh349
 * 
 */
public class ConnectedEdge {
	private Node node1;
	private Node node2;

	public ConnectedEdge(Node n1, Node n2) {
		// n1 is always to the left
		if (n1.compareTo(n2) == 1) {
			node2 = n1;
			node1 = n2;
		} else {
			node1 = n1;
			node2 = n2;
		}
	}

	public Node getNode1() {
		return node1;
	}

	public Node getNode2() {
		return node2;
	}

	public boolean isNode() {
		return node1.equals(node2);
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(node1.toString());
		sb.append(" ");
		sb.append(node2.toString());
		return sb.toString();
	}

	public static void main(String[] args) {
		ConnectedEdge edge = new ConnectedEdge(new Node(1.12012, 1.3131313),
				new Node(1.12012, 1.3131313));
		System.out.println(edge.isNode());
	}
}
